<template>
  <div class="dateLeft" style="padding:10px;width: 100%;">
      <el-date-picker
        @change="changeTime"
        v-model="gTime"
        :clearable="false"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
    </el-date-picker>
  </div>
</template>
<script>
export default {
  data() {
    return {
      gTime: new Date()
    };
  },
  mounted() {
    this.emitTime();
  },

  methods: {
    emitTime() {
      var lastDate = this.$utils.getDateStr(-1);
      this.gTime = this.$utils.formateDate(lastDate);
      this.$emit("onTime", lastDate);
    },
    changeTime(res) {
      var lastDate = this.$utils.parseTime(res, "{y}-{m}-{d}");
      this.$emit("onTime", lastDate);
    }
  }
};
</script>

<style>
@import "../../styles/element-ui/date/dateLeft.css";
</style>
